Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Default num_jobs to max CPUs minus 1 if not specified #788

Merged
merged 1 commit into from
Jul 17, 2022

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Jul 17, 2022

This doesn't change the behavior when --jobs/-j is specified as a
command-line argument or in SCONSFLAGS.

The SCons hack used to know if num_jobs was set by the user is derived
from the MongoDB setup.

We use os.cpu_count() for portability (available since Python 3.4).

With 4 CPUs or less, we use the max. With more than 4 we use max - 1 to
preserve some bandwidth for the user's other programs.

Equivalent to upstream Godot godotengine/godot#63087.

Should speed up macOS builds by using 3 cores by default (and dehardcodes -j4 in the Makefile).

@akien-mga akien-mga added enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup cherrypick:3.x labels Jul 17, 2022
@akien-mga akien-mga requested review from Faless and bruvzg July 17, 2022 10:35
This doesn't change the behavior when `--jobs`/`-j` is specified as a
command-line argument or in `SCONSFLAGS`.

The SCons hack used to know if `num_jobs` was set by the user is derived
from the MongoDB setup.

We use `os.cpu_count()` for portability (available since Python 3.4).

With 4 CPUs or less, we use the max. With more than 4 we use max - 1 to
preserve some bandwidth for the user's other programs.
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason not to use all (or almost all) core I see, it can mess up output if multiple processes printing errors at the same time (usually it happens when making an invalid change to the widely used header), but in this case you can always use -j1.

@akien-mga akien-mga merged commit 3ceb321 into godotengine:master Jul 17, 2022
@akien-mga akien-mga deleted the scons-num_jobs-default-max branch July 17, 2022 13:43
akien-mga added a commit that referenced this pull request Jul 18, 2022
@akien-mga
Copy link
Member Author

(and dehardcodes -j4 in the Makefile)

Actually I had missed git adding it... now pushed with c2b35fb.

@akien-mga
Copy link
Member Author

Cherry-picked for 3.5.

@akien-mga akien-mga added this to the 4.0 milestone Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants